#!/usr/bin/env python3
# -*- coding: utf-8 -*-

""" numpy的运算 """

__auther__ = 'igofishing'

import numpy as np

a = np.array([[1, 2, 3], [4, 5, 6]])

b = np.arange(6).reshape((3, 2))

print(a)
print(b)

print(a.dot(b))

print('-------------------------------')


d = np.linspace(1, 100, 10).reshape((2, 5))

print(d)
print(d**2)

print('-------------------------------')

e = np.sin(d)

print(e)

print(e > 0)

print('-------------------------------')

f = np.random.random((4, 3))

print(f)
print(np.sum(f, axis=1))
print(np.max(f))
print('逐行排序', np.sort(f))


print('-------------------------------')

g = np.arange(2, 14).reshape((3, 4))
print(g)
print('最小坐标', np.argmin(g, axis=0))
print('平均数', g.mean())
print('中位数', np.median(g))
print('斐波那契数列', np.cumsum(g))
print('矩阵转置', g.T)
# print('矩阵转置', np.transpose(g))
print('矩阵矫正', np.clip(g, 4, 8))

print('元素相差', np.diff(g))

print('非零', np.nonzero(g))

